﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{

    public partial class DiagnosTableForm : Form
    {
        List<Diagnos> diagList = new List<Diagnos>();

        public DiagnosTableForm()
        {
            createTestData();
            InitializeComponent();
            //diagGrid.Rows[0].Cells[0].Value = "1";
            //diagGrid.Rows.Add();
            setTestDataToGrid();
        }

        void createTestData()
        {
            Diagnos d1 = new Diagnos(1, "Cold", "just a cold");
            Diagnos d2 = new Diagnos(2, "Flu", "just a flu");
            diagList.Add(d1);
            diagList.Add(d2);
        }

        void setTestDataToGrid()
        {
            diagGrid.Rows.Add(diagList.Count);
            for (int i = 0; i < diagList.Count; i++)
            {
                Diagnos d = diagList[i];
                diagGrid.Rows[i].Cells[0].Value = d.id;
                diagGrid.Rows[i].Cells[1].Value = d.name;
                diagGrid.Rows[i].Cells[2].Value = d.description;
            }
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            DiagnosDetailsForm testDialog = new DiagnosDetailsForm();

            // Show testDialog as a modal dialog and determine if DialogResult = OK.
            if (testDialog.ShowDialog(this) == DialogResult.OK)
            {
                // Read the contents of testDialog's TextBox.
                //this.txtResult.Text = testDialog.TextBox1.Text;
            }
            else
            {
                //this.txtResult.Text = "Cancelled";
            }
            testDialog.Dispose();
        }
    }
}
